package com.sunmouse.toolkit.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.sunmouse.toolkit.R;
import com.sunmouse.toolkit.constant.Config;
import com.sunmouse.toolkit.util.PageUtil;


public class ContentActivity extends ToolbarActivity {

    private Fragment mFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_content);
    }


    @Override
    public void initNav() {
        index = getIntent().getIntExtra(Config.Key.INDEX, -1);
        if (index==-1)return;
        setTitle(getTitle(index));
        getToolbar().setNavigationOnClickListener(mDefaultNavClick);

    }

    @Override
    public void init() {
        if (index < 0) return;
        this.mFragment = PageUtil.getFragment(index);
        this.mFragment.setArguments(getIntent().getExtras());
        this.mManager.beginTransaction()
                .add(R.id.fragment_container, mFragment)
                .commit();
    }


    /**
     * get title
     */
    private String getTitle(int index) {
        String title = "";
        switch (index) {

        }

        return title;
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (mFragment != null) mFragment.onActivityResult(requestCode, resultCode, data);
    }


}
